import { ref, reactive, toRefs, onMounted } from 'vue';

export function useDialog(props, context) {

    const dialogEl = ref(null);
    const state = reactive({
        dialogH: null
    })

    const cancel = () => {
        context.emit('cancel');
    }
    const confirm = () => {
        context.emit('confirm');
    }

    onMounted(() => {
        state.dialogH = dialogEl.value.offsetHeight;
    })

    return {
        dialogEl,
        ...toRefs(state),
        cancel,
        confirm
    }
}